// pages/redirect/redirect.js
Page({

    /**
     * 页面的初始数据
     */
    data:{
        imageSrc:[""],
        Username:"",
        id:"",
        datas:{
            id:0,
            username:"",
            title:"房产资源1",
            kind:"出租",
            phone:"18822067130",
            lease:"1年",
            isjoint:"",
            requirement:"只限女生",
            funiture:"",
            rights:"",
            type:"一室一厅",
            orientation:"南",
            floor:"3/6",
            decoration:"精装",
            elevator:"有电梯",
            date:"",
            area:20,
            price:0,
            location:"格园1斋357室",
            date:"2020/9/3",
            picture:"/static/source/房1.png",
            other:""
        }
    },
    

    /**
     * 生命周期函数--监听页面加载,会在页面加载后执行，并接收?=后面的参数
     */
    onLoad: function (options) {
        console.log(options)
        var that=this
        this.setData({
            datas:{id:options.id}
            
        })
        console.log(this.data.datas.id)
        var loctoken=wx.getStorageSync('token')
        var locusername=wx.getStorageSync('username')
        wx.request({
            url: 'http://172.23.144.125:8081/house/v1/info/'+locusername+'/'+loctoken+'/'+that.data.datas.id,
            method:"GET",
            data:{

            },
            success:function(res)
            {
                if(res.data.code==200)
                {
                    console.log(res.data)
                  that.setData({datas:res.data.info})
                  console.log(that.data.datas.title)
                   
                  that.setData({imageSrc:that.data.imageSrc.concat(res.data.info.picture)})
                }
                else{
                    wx.showToast({
                      title: res.data.message,
                      duration: 2000,
                      icon: "error",

                    })
                }
            },
            fail:function(res){
                wx.showToast({
                  title: '请求页面失败，请检查您的网络',
                  duration:2000,
                  icon:"error"
                })
            }
        })

       
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },
    Tel:function()
    {
        wx.makePhoneCall({
          phoneNumber:this.data.datas.phone,
        })
    },
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    Sendusername :function(Username)
    {
        this.setData(this.data.Username=Username)
        wx.request({
          url: 'http://localhost:8080/user/login',
          data:{
              password:"Muradil",
              username:"helloworld"

          },
          header:{
              'content-type':'application/json'
          },
          success (res) {
            console.log(res.data)
          }
        })
    }
})